<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------

namespace app\index\controller;
use app\common\controller\Front;

class Index extends Front
{
	//网站首页
	public function index()
	{
	    //设置SEO
		$this->setSeo(config('web_site_title'), config('web_site_keyword'), config('web_site_description'));
		
		$content = M('xzwm');
		// 走进轩陶
		$zjxt = $content->where(['id'=>5])->find();
		// 关于我们
		$gywm = $content->where(['id'=>6])->find();
		// 企业文化   
		$qywh = $content->where(['id'=>7])->find();
		// 荣誉资质
		$ryzz = M('zzry')->where(['id'=>1])->find();
		// 选择我们
		$xzwm = $content->where(['id'=>1])->find();
		$xzwmList = $content->where(['is_top'=>1, 'status'=>1])->order('id asc')->paginate(3);
		// 获取工程案例的城市
		$city = getAttrConf(8, 'city');
		// 工程案例
		$case = M('Cases')->where(['status'=>1, 'is_top'=>1])->order('id desc')->paginate(9);
		// 新闻资讯
		$news = M('News')->where(['status'=>1, 'is_top'=>1])->order('id desc')->paginate(3);
		// 联系方式
		$contact = M('contact')->where(['id'=>1])->find();
		$data = array(
		    'zjxt'    => $zjxt,
		    'gywm'    => $gywm,
		    'qywh'    => $qywh,
		    'ryzz'    => $ryzz,
		    'xzwm'    => $xzwm,
		    'xzwmList'    => $xzwmList,
		    'city'    => $city,
		    'case'    => $case,
		    'news'    => $news,
		    'contact' => $contact,
		);
		$this->assign($data);
		return $this->fetch();
	}
	
	/**
	 * 首页banner广告
	 * @return mixed|string
	 */
	public function indexbanner()
	{
	    return $this->fetch();
	}
	/**
	 * 首页热销产品
	 * @return mixed|string
	 */
	public function hotpro()
	{
	    $list = M('pro')->where(['p_hot'=>1])->order('create_time desc')->paginate(20);
	    $hot = [];
	    foreach ($list as $k => $v)
	    {
	        $hot[$k]['id'] = $v['id'];
	        $hot[$k]['title'] = $v['title'];
	        $hot[$k]['category'] = get_category_name($v['category_id']);
	        $hot[$k]['images'] = get_cover_list($v['p_covers']);
	    }
	    $this->assign(['list'=>$hot]);
	    return $this->fetch();
	}
	/**
	 * 首页新品推荐
	 * @return mixed|string
	 */
	public function newpro()
	{
	    $list = M('pro')->where(['p_new'=>1])->order('create_time desc')->paginate(20);
	    $hot = [];
	    foreach ($list as $k => $v)
	    {
	        $hot[$k]['id'] = $v['id'];
	        $hot[$k]['title'] = $v['title'];
	        $hot[$k]['category'] = get_category_name($v['category_id']);
	        $hot[$k]['images'] = get_cover_list($v['p_covers']);
	    }
	    $this->assign(['list'=>$hot]);
	    return $this->fetch();
	}
}
